﻿<?php
require_once('konfiguration.html');


$handle=opendir ("alltranslations6/");
mysql_query("SET NAMES 'utf8'"); 
while ($file_name = readdir ($handle))
{
   
   $lines=file("alltranslations6/".$file_name);
   $work_array=explode("-",$file_name);
   $key=$work_array[0]."_".$work_array[1];
   print "key $key";
   $num_rows=mysql_num_rows(mysql_query("SELECT DISTINCT `language_combo`
                                   FROM `alltranslations2`
                                   WHERE `language_combo` LIKE '$key%'"));
	if ($num_rows) $key_number=$num_rows + 1;else $key_number="";		   
    $key.=$key_number;
		     print "<BR>newkey $key";
   		     
   foreach($lines as $line)
   { 
  
      $index+=1;
      preg_match_all('/^(.*?)[\s]{2,6}(.*?)[\s]{2,6}(.*)/',$line,$matches,PREG_PATTERN_ORDER);
      if ($matches[3]) //AND $index <=100) 
      { 
         
	 print "$key<BR>";
	  $words=preg_split('/[,;]/',$matches[1][0] );
          $translations=preg_split('/[,;]/',$matches[2][0] );
	  $area=trim($matches[3][0]);
         	 
      
      
      print_r($matches);
      print_r($words);
      print_r($translations);
      print $area;
      
      foreach ($words as $word)
      {
        foreach ($translations as $translation) 
        { 
         
	 $translation=trim($translation);$word=trim($word);
	if (in_array($area,array('verb','adjective','article','adverb','pronoun','preposition','conjunction'))) {
	        mysql_query("INSERT INTO alltranslations2 (language_combo, word, translation, `word class`) VALUES ('$key','$word',
               '$translation','$area')"); print "<BR>word CLAAAAAAAAAAAAAAAAAAAAAAAAAASS";}
        else
                {mysql_query("INSERT INTO alltranslations2 (language_combo, word, translation, area) VALUES ('$key','$word',
                '$translation','$area')");print "<BR>KEINEEEE word class";}
       
       
        }
       
       set_time_limit(10);
      }
      }
      }
      
}


closedir($handle);

?>